/**
 * Created with IntelliJ IDEA.
 * Description:自定义登录异常
 */
public class Main {
    public final static String name = "ming";
    public final static String password = "123";

    static class NameException extends Exception{
        public NameException(String name){
            super(name);
        }
    }

    static class PasswordException extends Exception{
        public PasswordException(String password){
            super(password);
        }
    }

    public static void fun(String usename, String password) throws NameException,PasswordException{
        if(!Main.name.equals(usename)|| !Main.password.equals(password)){
            throw new NameException("用户名或者密码错误！");
        }
//        if(!Main.password.equals(password)){
//            throw new PasswordException("密码错误！");
//        }
    }

    public static void main(String[] args) {
        try {
            fun("ming","1234");
        }catch (NameException | PasswordException e){
            e.printStackTrace();
        }
    }
}
